package cn.itsource.org.service.impl;

import cn.itsource.basic.domain.BaseQuery;
import cn.itsource.basic.domain.DeparmentQuery;
import cn.itsource.basic.util.PageList;
import cn.itsource.org.domain.Department;
import cn.itsource.org.mapper.DepartmentMapper;
import cn.itsource.org.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;


    @Override
    public void insert(Department department) {
        department.init();
        departmentMapper.insertSelective(department);
    }

    @Override
    public void update(Department department) {
        department.init();
        departmentMapper.updateByPrimaryKeySelective(department);
        System.out.println(department);
    }

    @Override
    public PageList<Department> findPage(BaseQuery baseQuery, String key) {
        return departmentMapper.findPage(baseQuery,key);
    }

    @Override
    public void delete(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void deleteBatch(List<Long> ids) {
        departmentMapper.deleteBatch(ids);
    }

    @Override
    public List<Department> findAll() {
        return departmentMapper.finAll();
    }

    @Override
    public Department findOne(Long id) {
        return departmentMapper.findOne(id);
    }

    @Override
    public PageList<Department> page(DeparmentQuery query) {
        return departmentMapper.page(query);
    }
}
